home *** CD-ROM | disk | FTP | other *** search
/ Programming Sound Cards / Programming Sound Cards.iso / sound_45 / modcomp.h < prev    next >
C/C++ Source or Header  |  1995-01-01  |  5KB  |  189 lines

  1. /* BEGIN DAVID LAI COPYRIGHT ********************************************* */
  2. /*
  3. (C) Copyright David Lai 1993, 1994.  All rights reserved.
  4.  
  5. The source code is copyright by David Lai, however it is freely
  6. distributable and released for unrestricted use.  Users may copy or modify 
  7. this source code without charge, provided all copyright
  8. notices remain intact in all the source code.  Portions of the source code
  9. copyright by their respective copyright holders and are covered
  10. under different agreements, however the source code used has
  11. specifically been marked distributable royalty-free.
  12.  
  13. You can do whatever you want with it, even charge money for it, if
  14. you find a sucker willing to pay for it.  This is not shareware, the program
  15. is not crippled in any way, do not send money.  You can e-mail comments
  16. to the electronic mail address below, or fax to the fax number below.
  17.  
  18. If you add a feature thats useful, or do a new port, you can send
  19. the context diffs to the e-mail address below.  I may include it in
  20. subsequent releases.  Your code must specifically be marked
  21. freely distributable, I will not include code marked otherwise.
  22.  
  23. THE SOURCE CODE IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING
  24. THE WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
  25. PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
  26.  
  27. The source code is provided with no support and without any obligation on
  28. the part of David Lai to assist in its use, correction,
  29. modification or enhancement.
  30.  
  31. DAVID LAI SHALL HAVE NO LIABILITY WITH RESPECT TO THE
  32. INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY THIS SOFTWARE
  33. OR ANY PART THEREOF.
  34.  
  35. In no event will David Lai be liable for any lost revenue
  36. or profits or other special, indirect and consequential damages, even if
  37. David Lai has been advised of the possibility of such damages.
  38.  
  39. David Lai
  40. 1370 McKendrie St
  41. San Jose, CA 95126
  42. fax: 408-241-4615
  43.  
  44. lai%fastfood@daver.bungi.com
  45.  
  46. */
  47. /* END   DAVID LAI COPYRIGHT ********************************************* */
  48.  
  49. #define PRODUCT_ID    "Mod Compiler v0.00"
  50.  
  51. #define MOD_TAGSIZE 4
  52. #define TAG_OFFSET_15 600L
  53. #define TAG_OFFSET_31 1080L
  54. #define CHECK_31_INST_OFFSET 470L
  55. #define SAMPLE_NAME_SIZE    22
  56. #define MAX_INSTRUMENTS    31
  57. #define MOD_NAME_LENGTH    20
  58. #define SAMPLE_HEADER_OFFSET 20
  59. #define SAMPLE_HEADER_LENGTH    30
  60. #define PATTERN_TABLE_SIZE 128
  61. #define NOTESIZE 4
  62. #define LINES_PER_PATTERN 64
  63. #define MAX_VALID_END_JUMP_POS 126
  64. #define NOTES_PER_OUTPUT_LINE    4
  65. #define SAMPLE_BUFFER_SIZE    4096
  66. #define SAMPLE_IGNORE_BYTES    2    /* ignore this # of bytes at start of
  67.                        each sample */
  68. enum sample_format
  69.     {
  70.     Internal,    /* internal array */
  71.     Wave,        /* Microsoft .wav */
  72.     Voc,        /* Creative Labs' .voc */
  73.     Sample,        /* .SAM, raw 8-bit signed */
  74.     Ascii        /* ascii -128 to 127 */
  75.     };
  76.  
  77. struct sample_format_info
  78.     {
  79.     char *name;
  80.     };
  81.  
  82. enum main_effects
  83.     {
  84.     Arpeggio=0,
  85.     SlideUp,
  86.     SlideDown,
  87.     TonePortamento,
  88.     Vibrato,
  89.     TonePortamentoVolumeSlide,
  90.     VibratoVolumeSlide,
  91.     Tremolo,
  92.     NOTUSED,
  93.     SetSampleOffset,
  94.     VolumeSlide,
  95.     PositionJump,
  96.     SetVolume,
  97.     PatternBreak,
  98.     Extended,
  99.     SetSpeed,
  100.     SetFilter=0xE0,
  101.     FineSlideUp,
  102.     FineSlideDown,
  103.     GlissandoControl,
  104.     SetVibratoWaveform,
  105.     SetFinetune,
  106.     JumptoLoop,
  107.     SetTremoloWaveform,
  108.     NOTUSED2,
  109.     RetrigNote,
  110.     FineVolumeSlideUp,
  111.     FineVolumeSlideDown,
  112.     NoteCut,
  113.     NoteDelay,
  114.     PatternDelay,
  115.     InvertLoop,
  116.     Normal=0xFF
  117.     };
  118.  
  119. struct effect_info
  120.     {
  121.     char *name;
  122.     int  number_of_args;
  123.     };
  124.  
  125. struct sample
  126.     {
  127.     char    name[SAMPLE_NAME_SIZE+1];
  128.     uint16    length;
  129.     uint16    orig_length;
  130.     signed char    finetune;
  131.     unsigned char    volume;
  132.     uint16    rpt_offset;
  133.     uint16    rpt_length;
  134.     off_t    data_offset;    /* offset in file of sample data */
  135.     char    *sample_filename;
  136.     };
  137.  
  138.  
  139. #ifdef BE
  140. struct note
  141.     {    /* big endian (native amiga) version */
  142.     unsigned    sample_upper:4;
  143.     unsigned    sample_period_upper:4;
  144.     unsigned    sample_period_lower:8;
  145.     unsigned     sample_lower:4;
  146.     unsigned    effect_main:4;
  147.     unsigned arg1:4;
  148.     unsigned arg2:4;
  149.     };
  150. #else
  151. struct note
  152.     {    /* little endian version */
  153.     unsigned    sample_period_upper:4;
  154.     unsigned    sample_upper:4;
  155.     unsigned    sample_period_lower:8;
  156.     unsigned    effect_main:4;
  157.     unsigned     sample_lower:4;
  158.     unsigned arg2:4;
  159.     unsigned arg1:4;
  160.     };
  161. #endif
  162.  
  163. union u_note
  164.     {    /* map the word in the file to the note structure */
  165.     struct note note;
  166.     uint32    note_word;    /* as it is in the file */
  167.     };
  168.  
  169. #define SAMPLE_NUMBER(x) (((x)->note.sample_upper << 4) | (x)->note.sample_lower)
  170. #define SAMPLE_PERIOD(x) (((x)->note.sample_period_upper << 8) | (x)->note.sample_period_lower)
  171. #define EFFECT(x) ((x)->note.effect_main)
  172. #define EXT_EFFECT(x) (((x)->note.effect_main << 4) | (x)->note.arg1)
  173. #define ARG1(x) ((x)->note.arg1)
  174. #define ARG2(x) ((x)->note.arg2)
  175. #define BIGARG(x) ((ARG1(x)<<4) + ARG2(x))
  176. #define SMALLARG(x) (ARG2(x))
  177. #define SIGN_EXT_NIBBLE(n) ((((n)&8)==8)?(((n)&0xf)-16):((n)&0xf))
  178.  
  179. #define WARN_CHECK (warns++>30?err_exit("Too many warnings, Aborting",NULL):NULL)
  180.  
  181. #if 0
  182. $Id: modcomp.h,v 1.1 1994/03/19 09:21:31 dlai Exp $
  183. $Log: modcomp.h,v $
  184.  * Revision 1.1  1994/03/19  09:21:31  dlai
  185.  * Initial revision
  186.  *
  187.  
  188. #endif
  189.